<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>档案查询</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
</head>
<style>
    .layui-form-pane .layui-form-label {
        width: auto !important;
    }

    .layui-table-cell {
        height: auto !important;
        white-space: normal;
    }

</style>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <fieldset class="table-search-fieldset">
            <legend>搜索信息</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">查询方式</label>
                            <div class="layui-input-inline">
                                <select name="searchWay" lay-filter="searchSelect" lay-reqtext="请选择查询方式"
                                        lay-verify="required">
                                    <option value="" selected>请选择查询方式</option>
                                    <option value="1">按档案编号查询</option>
                                    <option value="2">按柜子编号查询</option>
                                    <option value="3">按道路名称查询</option>
                                    <option value="4">按箱门编号查询</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <input type="text" id="keyInput" lay-reqtext="请输入关键词哦" lay-verify="required" name="keyWord"
                                       placeholder="请选择查询方式" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn  layui-btn-primary" lay-submit
                                    lay-filter="data-search-btn"><i class="layui-icon"> 搜 索
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>
        <fieldset class="table-search-fieldset">
            <legend>档案列表</legend>
            <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
        </fieldset>
    </div>
</div>
<script src="/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'table', 'tree', 'util', 'laydate', 'layer', 'element'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            laydate = layui.laydate,
            layer = layui.layer,
            element = layui.element,
            util = layui.util;


        table.render({
            elem: '#currentTableId',
            url: '/api/table.json',
            toolbar: '#toolbar',
            width: 1250,
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            cols: [
                [
                    {field: 'id', width: 150, title: '档案编号'},
                    {field: 'name', width: 140, title: '档案名称'},
                    {field: 'chest_id', width: 120, title: '柜子编号'},
                    {field: 'chest_id', width: 150, title: '箱子编号'},
                    {field: 'address', width: 190, title: '道路名称'},
                    {field: 'create_time', width: 150, title: '创建时间'},
                    {field: 'update_time', title: '更新时间', width: 150},
                    {field: 'remark', width: 300, title: '备注'},
                ]
            ],
            id: 'recordReload',
            limits: [10, 15, 20, 25, 50, 100],
            limit: 15,
            page: true
        });

        // 监听搜索操作:部门
        form.on('submit(data-search-btn)', function (data) {
            var result = data.field;

            //执行搜索重载
            table.reload('recordReload', {
                url: 'XXXXXX'
                ,
                page: {
                    curr: 1
                }
                , where: {
                    id: result.id
                }
            }, 'data');

            return false;
        });

        //监听表格复选框选择
        table.on('checkbox(currentTableFilter)', function (obj) {
            console.log(obj)
        });

        //监听下拉选择框  搜索方式
        form.on('select(searchSelect)', function (data) {
            let way = parseInt(data.value);
            switch (way) {
                case 1:
                    $("#keyInput").prop("placeholder", "请输入档案编号");
                    break;
                case 2:
                    $("#keyInput").prop("placeholder", "请输入柜子编号");
                    break;
                case 3:
                    $("#keyInput").prop("placeholder", "请输入道路名称");
                    break;
                case 4:
                    $("#keyInput").prop("placeholder", "请输入箱门编号");
                    break;
                default:
                    $("#keyInput").prop("placeholder", "请选择查询方式");
            }

        });

    });
</script>
</body>
</html>